package com.haha.qqchannelbot.listener;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Random;
import java.util.Set;
import java.util.stream.Stream;

import static java.lang.Math.random;

public class LotteryTicketUtil {


    public static String numbers() {

        Set<Integer> red = new HashSet();

        StringBuilder sb = new StringBuilder();

        while (red.size() != 5){
            red.add((int) (random()* 34 + 1));
        }
        Stream<Integer> sorted = red.stream().sorted();
        sb.append("红：");
        for (Object o : sorted.toArray()) {
            sb.append(o + " ; ");
        }

        Set<Integer> blue = new HashSet();

        while (blue.size() != 2){
            blue.add((int) (random()* 11 + 1));
        }
        Stream<Integer> sorted2 = blue.stream().sorted();
        sb.append("  蓝：");
        for (Object o : sorted2.toArray()) {
            sb.append(o + " ; ");
        }

        return sb.toString();
    }

    public static void numbers2() {

        Integer[] red = {1,2,3,4,5,6,7,
                8,9,10,11,12,13,14,
                15,16,17,18,19,20,21,
                22,23,24,25,26,27,28,
                29,30,31,32,33,34,35};

        Integer[] blue = {1,2,3,4,5,6,7,8,9,10,11,12};

        List<Integer> red0 = new ArrayList<>(36);
        for (int i = 1; i <= 35; i++) {
            red0.add(i);
        }

        List<Integer> blue0 = new ArrayList<>(13);
        for (int i = 1; i <= 12; i++) {
            blue0.add(i);
        }
        List<Integer> red1 = new ArrayList<>(5);
        for (int i = 0; i < 5; i++) {
            int index = (int) (random() * (35 - i));
            red1.add(red0.get(index));
            red0.remove(index);
        }
        Collections.sort(red1);
        System.out.print("红:");
        for (Integer num : red1) {
            System.out.print(num + " ; ");
        }

        List<Integer> blue1 = new ArrayList<>(2);
        for (int i = 0; i < 2; i++) {
            int index = (int) (random() * (12 - i));
            blue1.add(blue0.get(index));
            blue0.remove(index);
        }
        Collections.sort(blue1);
        System.out.print("  蓝:");
        for (Integer num : blue1) {
            System.out.print(num + " ; ");
        }

        System.out.println("");
    }


    public static String numbers3() {

        StringBuilder sb = new StringBuilder();

        Integer[] red = {1,2,3,4,5,6,7,
                8,9,10,11,12,13,14,
                15,16,17,18,19,20,21,
                22,23,24,25,26,27,28,
                29,30,31,32,33};

        Integer[] blue = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16};

        List<Integer> red0 = new ArrayList<>(34);
        for (int i = 1; i <= 33; i++) {
            red0.add(i);
        }

        List<Integer> blue0 = new ArrayList<>(17);
        for (int i = 1; i <= 16; i++) {
            blue0.add(i);
        }
        List<Integer> red1 = new ArrayList<>(6);
        for (int i = 0; i < 6; i++) {
            int index = (int) (random() * (33 - i));
            red1.add(red0.get(index));
            red0.remove(index);
        }
        Collections.sort(red1);
        sb.append("红:");
        System.out.print("红:");
        for (Integer num : red1) {
            sb.append(num).append(" ; ");
            System.out.print(num + " ; ");
        }

        List<Integer> blue1 = new ArrayList<>(1);
        for (int i = 0; i < 1; i++) {
            int index = (int) (random() * (16 - i));
            blue1.add(blue0.get(index));
            blue0.remove(index);
        }
        Collections.sort(blue1);
        System.out.print("  蓝:");
        sb.append("  蓝:");
        for (Integer num : blue1) {
            System.out.print(num + " ; ");
            sb.append(num).append(" ; ");
        }

        System.out.println("");
        return sb.toString();
    }


    public static String pailie5() {
        StringBuilder sb = new StringBuilder();

        Random random = new Random();
        sb.append("排列5：");
        for (int i = 0; i < 5; i++) {
            sb.append(random.nextInt(0, 9)).append(" ; ");
        }

        return sb.toString();
    }


}
